//存储的方法
export const setItem = (key, val) => {
  if (typeof val === "object") {
    localStorage.setItem(key, JSON.stringify(val));
  } else {
    localStorage.setItem(key, val);
  }
};

// setItem("token", 22222222);

//读取的方法
export const getItem = (key) => {
    const data = localStorage.getItem(key)
    try {
        return JSON.parse(data)
    } catch (error) {
        return data
    }
}
// let res1 = getItem('token')


//删除
export const removeItem = (key) => {
    localStorage.removeItem(key)
}

